package com.camartsApp.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.camartsApp.entity.UserRelationship;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface UserRelationshipMapper extends BaseMapper<UserRelationship> {
    // 1. 自定义方法：根据关注者和被关注者ID查询关系
    UserRelationship findByFollowerAndFollowing(@Param("followerId") Long followerId,
                                                @Param("followingId") Long followingId);

    // 2. 自定义方法：更新关系状态
    int updateStatus(@Param("followerId") Long followerId,
                     @Param("followingId") Long followingId,
                     @Param("status") int status);
    List<Long> selectFollowingIdsByFollowerId(@Param("userId") Long userId);
    /**
     * 根据被关注者ID查询所有粉丝ID（follower_id）
     */
    List<Long> selectFollowerIdsByFollowingId(@Param("userId") Long userId);

    /**
     * 判断某用户是否已关注目标用户
     */
    Integer isFollowing(@Param("followerId") Long followerId,
                        @Param("followingId") Long followingId);

}